package com.sjf.day01;

/**
 * @author <sjf753@qq.com>
 * @since 2021/12/6 13:50
 **/
public class test02 {

    public static void find1Num(int[] arr){
        int eor=0;
        for(int a:arr){
            eor^=a;
        }
        System.out.println(eor);
    }

    public static void find2Num(int[] arr){
        int eor=0;
        for(int a:arr){
            eor^=a;
        }

        int rightOne= eor&(~eor + 1);//得到最右边的1
        int onlyOne = 0;//这是eor'
        for(int cur:arr){
            if((cur & rightOne) ==0){
                onlyOne^=cur;
            }
        }
        System.out.println(onlyOne+ "  "+(eor ^ onlyOne));
    }

    public static void swap(int[] num, int i, int j){
        num[i]=num[i]^num[j];
        num[j]=num[i]^num[j];
        num[i]=num[i]^num[j];
    }

    public static void main(String[] args) {
        int[] a =new int[]{2,3,4,4,3,2,1,1,1,5,5,5};
        find2Num(a);
    }
}
